$OpenBSD: patch-util_c,v 1.9 2014/11/29 19:16:48 naddy Exp $
--- util.c.orig	Thu Nov 21 16:54:45 2013
+++ util.c	Sat Nov 29 17:48:42 2014
@@ -41,10 +41,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <wchar.h>
 
 #include "ls.h"
 #include "extern.h"
 
+#ifdef SMALL
 int
 putname(char *name)
 {
@@ -54,12 +56,57 @@ putname(char *name)
 		putchar((!isprint((unsigned char)*name) && f_nonprint) ? '?' : *name);
 	return len;
 }
+#else
+int
+putname(char *name)
+{
+	int len;
+	wchar_t wc;
+	size_t n;
+	mbstate_t mbs;
+	int w;
 
+	len = 0;
+	bzero(&mbs, sizeof(mbs));
+	while (*name) {
+		n = mbrtowc(&wc, name, MB_CUR_MAX, &mbs);
+		if (n == 0)
+			break;
+		if (n == (size_t)-1 || n == (size_t)-2) {
+			/* Filename encoding doesn't match locale encoding.
+			 * Fall back to printing single bytes. */
+			while (*name) {
+				putchar((!isprint(*name) && f_nonprint)
+				    ? '?' : *name);
+				len++;
+				name++;
+			}
+			return len;
+		}
+		name += n;
+		if (!iswprint(wc) && f_nonprint) {
+			putchar('?');
+			len++;
+		} else {
+			putwchar(wc);
+			w = wcwidth(wc);
+			if (w > 0)
+				len += w;
+		}
+	}
+	return len;
+}
+#endif
+
 void
 usage(void)
 {
 	(void)fprintf(stderr,
+#ifdef COLORLS
+	    "usage: %s [-1AaCcdFfGgHhikLlmnopqRrSsTtux] [file ...]\n",
+#else
 	    "usage: %s [-1AaCcdFfgHhikLlmnopqRrSsTtux] [file ...]\n",
+#endif
 	    __progname);
 	exit(1);
 }
